package demo1;

public class Person implements Cloneable{
    public int age;
    public double score;
    public String name;
    public Money money=new Money();

    public Person(int age, double score, String name) {
        this.age = age;
        this.score = score;
        this.name = name;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {//1.重写父类Object的方法
//        return super.clone();
        Person tmp=(Person) super.clone();
        tmp.money=(Money) this.money.clone();
        return tmp;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", score=" + score +
                ", name='" + name + '\'' +
                '}';
    }
}
